package com.wss.day10;

import java.util.function.Supplier;

/**
 * @author wangshaoshuai
 * @desc TODO
 * @date 2025/5/7
 */
public class SupplierMax {
    public static int getMax(Supplier<Integer> supplier) {
        return supplier.get();
    }

    public static void main(String[] args) {
        int[] array = {1, 5, 3, 9, 2, 7};
        int max = getMax(() -> {
            int maxValue = array[0];
            for (int num : array) {
                if (num > maxValue) {
                    maxValue = num;
                }
            }
            return maxValue;
        });
        System.out.println("数组中的最大值是: " + max);
    }
}
